package plus.chendd.lock;

import java.util.concurrent.TimeUnit;

public class EndThread004 {
  public static void main(String[] args) throws InterruptedException {
    Thread t1 = new Thread(() -> {
      while (true) {
        try {
          Thread.sleep(1000);
          System.out.println("~~~");
        } catch (Exception e) {
          System.out.println("抛出异常");
          return;
        }
      }
    });
    
    t1.start();
    TimeUnit.SECONDS.sleep(2);
    
    t1.interrupt();
  }
}
